package com.androidx.p013lv.mine.activity;

import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import com.alibaba.android.arouter.launcher.ARouter;
import com.androidx.p013lv.base.Constance;
import com.androidx.p013lv.base.bean.UserAccount;
import com.androidx.p013lv.base.http.BaseRes;
import com.androidx.p013lv.base.interfaces.Key;
import com.androidx.p013lv.base.p015ui.BaseActivity;
import com.androidx.p013lv.base.utils.SpUtils;
import com.androidx.p013lv.mine.C1207R;
import com.androidx.p013lv.mine.databinding.ActivityWalletLayoutBinding;
import com.androidx.p013lv.mine.model.WalletModel;
import com.gyf.immersionbar.ImmersionBar;

/* renamed from: com.androidx.lv.mine.activity.WalletActivity */
public class WalletActivity extends BaseActivity<ActivityWalletLayoutBinding> {
    private WalletModel model;
    private int type = 1;

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initImmersionBar() {
        super.initImmersionBar();
        ImmersionBar.with(this).titleBar(((ActivityWalletLayoutBinding) this.binding).toolbar).init();
    }

    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public int setLayout() {
        return C1207R.C1212layout.activity_wallet_layout;
    }

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initView() {
        super.initView();
        this.model = (WalletModel) new ViewModelProvider(this).get(WalletModel.class);
        ((ActivityWalletLayoutBinding) this.binding).setType(Integer.valueOf(this.type));
        ((ActivityWalletLayoutBinding) this.binding).setClick(new OnClick());
        this.model.dataAccount().observe(this, new Observer<BaseRes<UserAccount>>() {
            /* class com.androidx.p013lv.mine.activity.WalletActivity.C12781 */

            public void onChanged(BaseRes<UserAccount> baseRes) {
                if (baseRes.getCode() == 200) {
                    UserAccount data = baseRes.getData();
                    ((ActivityWalletLayoutBinding) WalletActivity.this.binding).setUserAccount(data);
                    SpUtils.getInstance().setUserAccount(data);
                }
            }
        });
        this.model.userAccList(this);
    }

    /* renamed from: com.androidx.lv.mine.activity.WalletActivity$OnClick */
    public class OnClick {
        public OnClick() {
        }

        public void btnBack() {
            WalletActivity.this.finish();
        }

        public void goDetails() {
            if (!WalletActivity.this.isOnClick()) {
                ARouter.getInstance().build(Constance.HISTORY_DETAIL).withInt("type", WalletActivity.this.type).navigation();
            }
        }

        public void switchBalanceOrGold(int i) {
            WalletActivity.this.type = i;
            ((ActivityWalletLayoutBinding) WalletActivity.this.binding).setType(Integer.valueOf(WalletActivity.this.type));
        }

        public void goTopUp(int i) {
            if (!WalletActivity.this.isOnClick()) {
                ARouter.getInstance().build(Constance.VIP_CENTER_ACTIVITY).withInt("type", i).withString(Key.BACK_TITLE, "錢包").navigation();
            }
        }
    }

    /* access modifiers changed from: protected */
    @Override // androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, com.androidx.p013lv.base.p015ui.BaseActivity
    public void onDestroy() {
        WalletModel walletModel = this.model;
        if (walletModel != null) {
            walletModel.cancelHttp();
        }
        super.onDestroy();
    }
}
